package org.example.struct.array;

/**
 * @author liyishan
 * @date 2023/8/9 10:44
 * @apiNote
 */

public class Test00717IsOneBitCharacter {

    public static void main(String[] args) {
        int[] bits = new int[]{1,0,0};
        System.out.println(test(bits));
    }

    /**
     * 从前往后遍历  如果遇到1就走两步  如果遇到0就走一步  看能不能走完
     * @param bits
     * @return
     */
    public static boolean test(int[] bits) {
        int i = 0;
        while(i<bits.length){
            if(i== bits.length -1){
                return true;
            }
            if(bits[i] == 1){
                i+=2;
            }else{
                i++;
            }
        }
        return false;
    }

    public static boolean test1(int[] bits) {
        int i = 0;
        while(i<bits.length){
            i += bits[i] +1;
        }
        return i == bits.length-1;
    }
}
